﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CTP.Exceptions
{
    /// <summary>
    /// 一般的异常
    /// </summary>
    internal class CommonException : Exception
    {
        public CommonException()
            : base()
        {
        }

        public CommonException(string message)
            : base(message)
        {
        }

        public override string ToString()
        {
            Exception innerEx=this.InnerException;
            string innerExStr="";
            while(innerEx!=null)
            {
                innerExStr+=innerEx.Message;
                innerEx=innerEx.InnerException;
            }

            string result = string.Format(
                "{0} \tMessage:{1} \tInnerException:{2} \tStackTrace:{3}",
                DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                Message,
                innerEx,
                StackTrace);

            return result;
        }
    }
}
